﻿namespace Innovative.ProXr
{
	public static partial class DirectApi
	{
		/// <summary>
		/// Provides commands to enable relay flashing.
		/// </summary>
		public static class Flash
		{
			/// <summary>
			/// Sets the Flash Rate of all Relay Flashers. A relay flasher turns relays on and off in the background automatically. 
			/// A speed value parameter is required from 0-255. This parameter controls the flash rate where 0 is the fastest0 
			/// and 255 is the slowest allowed speed.
			/// </summary>
			public static RelayCommandSet<bool, int> SetRate = new RelayCommandSet<bool, int>()
			{
				Commands = new RelayCommand[]
				{
					RelayCommand.Command254,
					RelayCommand.CreateReadOnlyCommand(1, 45),
					RelayCommand.CreateReadOnlyCommand(2, 0),
					RelayCommand.CreateNonOptionalParameterCommand(3, (new RelayByte[0]).CreateRange(0, 255))
				},
				ExpectedResults = new RelayByte[] { 85 },
				ResponseConverter = new Boolean85ResponseConverter(),
				Parameter1Converter = new Int32ParameterConverter()
			};

			/// <summary>
			/// Controls the On/Off Status of each of the 16 possible relay flashers. There are two optional parameters 
			/// for this command. 1-16 chooses a relay flasher to control, a value of 0 or 1 turns the flasher off or on.
			/// </summary>
			public static RelayCommandSet<bool, Flasher, int> SetIndividualRate = new RelayCommandSet<bool, Flasher, int>()
			{
				Commands = new RelayCommand[]
				{
					RelayCommand.Command254,
					RelayCommand.CreateReadOnlyCommand(1, 45),
					RelayCommand.CreateNonOptionalParameterCommand(3, (new RelayByte[0]).CreateRange(1, 16)),
					RelayCommand.CreateNonOptionalParameterCommand(3, (new RelayByte[0]).CreateRange(0, 255))
				},
				ExpectedResults = new RelayByte[] { 85 },
				ResponseConverter = new Boolean85ResponseConverter(),
				Parameter1Converter = new FlasherParameterConverter(),
				Parameter2Converter = new Int32ParameterConverter()
			};
		}
	}
}
